home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / cmds.fmt / grep.man < prev    next >
Encoding:
Text File  |  1991-10-06  |  9.2 KB  |  331 lines

  1.  
  2.  
  3.  
  4. GREP                      User Commands                      GREP
  5.  
  6.  
  7.  
  8. NNAAMMEE
  9.      grep, egrep, fgrep - print lines matching a regular expres-
  10.      sion
  11.  
  12. SSYYNNOOPPSSIISS
  13.      ggrreepp [ --CCVVbbcchhiillnnssvvwwxx ] [ --_n_u_m ] [ --AABB _n_u_m ] [ [ --ee ] _e_x_p_r |
  14.      --ff _f_i_l_e ] [ _f_i_l_e_s ... ]
  15.  
  16. DDEESSCCRRIIPPTTIIOONN
  17.      _G_r_e_p searches the files listed in the arguments (or standard
  18.      input if no files are given) for all lines that contain a
  19.      match for the given _e_x_p_r.  If any lines match, they are
  20.      printed.
  21.  
  22.      Also, if any matches were found, _g_r_e_p will exit with a
  23.      status of 0, but if no matches were found it will exit with
  24.      a status of 1.  This is useful for building shell scripts
  25.      that use _g_r_e_p as a condition for, for example, the _i_f state-
  26.      ment.
  27.  
  28.      When invoked as _e_g_r_e_p the syntax of the _e_x_p_r is slightly
  29.      different; See below.
  30.  
  31.      _F_g_r_e_p does not support regular expression metacharacters.
  32.  
  33. RREEGGUULLAARR EEXXPPRREESSSSIIOONNSS
  34.           (grep)    (egrep)   (explanation)
  35.  
  36.           _c         _c         a single (non-meta) character
  37.                               matches itself.
  38.  
  39.           .         .         matches any single character except
  40.                               newline.
  41.  
  42.           \?        ?         postfix operator; preceeding item
  43.                               is optional.
  44.  
  45.           *         *         postfix operator; preceeding item 0
  46.                               or more times.
  47.  
  48.           \+        +         postfix operator; preceeding item 1
  49.                               or more times.
  50.  
  51.           \|        |         infix operator; matches either
  52.                               argument.
  53.  
  54.           ^         ^         matches the empty string at the
  55.                               beginning of a line.
  56.  
  57.           $         $         matches the empty string at the end
  58.                               of a line.
  59.  
  60.  
  61.  
  62.  
  63. GNU Project             1988 December 13                        1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. GREP                      User Commands                      GREP
  71.  
  72.  
  73.  
  74.           \<        \<        matches the empty string at the
  75.                               beginning of a word.
  76.  
  77.           \>        \>        matches the empty string at the end
  78.                               of a word.
  79.  
  80.           [_c_h_a_r_s]   [_c_h_a_r_s]   match any character in the given
  81.                               class; if the first character after
  82.                               [ is ^, match any character not in
  83.                               the given class; a range of charac-
  84.                               ters may be specified by
  85.                               _f_i_r_s_t-_l_a_s_t; for example, \W (below)
  86.                               is equivalent to the class
  87.                               [^A-Za-z0-9]
  88.  
  89.           \( \)     ( )       parentheses are used to override
  90.                               operator precedence.
  91.  
  92.           \_d_i_g_i_t    \_d_i_g_i_t    \_n matches a repeat of the text
  93.                               matched earlier in the regexp by
  94.                               the subexpression inside the nth
  95.                               opening parenthesis.
  96.  
  97.           \         \         any special character may be pre-
  98.                               ceded by a backslash to match it
  99.                               literally.
  100.  
  101.           (the following are for compatibility with GNU Emacs)
  102.  
  103.           \b        \b        matches the empty string at the
  104.                               edge of a word.
  105.  
  106.           \B        \B        matches the empty string if not at
  107.                               the edge of a word.
  108.  
  109.           \w        \w        matches word-constituent characters
  110.                               (letters & digits).
  111.  
  112.           \W        \W        matches characters that are not
  113.                               word-constituent.
  114.  
  115.      Operator precedence is (highest to lowest) ?, *, and +, con-
  116.      catenation, and finally |.  All other constructs are syntac-
  117.      tically identical to normal characters.  For the truly
  118.      interested, the file dfa.c describes (and implements) the
  119.      exact grammar understood by the parser.
  120.  
  121. OOPPTTIIOONNSS
  122.      --AA _n_u_m
  123.           print <num> lines of context after every matching line
  124.  
  125.      --BB _n_u_m
  126.  
  127.  
  128.  
  129. GNU Project             1988 December 13                        2
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. GREP                      User Commands                      GREP
  137.  
  138.  
  139.  
  140.           print _n_u_m lines of context before every matching line
  141.  
  142.      --CC   print 2 lines of context on each side of every match
  143.  
  144.      --_n_u_m print _n_u_m lines of context on each side of every match
  145.  
  146.      --VV   print the version number on the diagnostic output
  147.  
  148.      --bb   print every match preceded by its byte offset
  149.  
  150.      --cc   print a total count of matching lines only
  151.  
  152.      --ee _e_x_p_r
  153.           search for _e_x_p_r; useful if _e_x_p_r begins with -
  154.  
  155.      --ff _f_i_l_e
  156.           search for the expression contained in _f_i_l_e
  157.  
  158.      --hh   don't display filenames on matches
  159.  
  160.      --ii   ignore case difference when comparing strings
  161.  
  162.      --ll   list files containing matches only
  163.  
  164.      --nn   print each match preceded by its line number
  165.  
  166.      --ss   run silently producing no output except error messages
  167.  
  168.      --vv   print only lines that contain no matches for the <expr>
  169.  
  170.      --ww   print only lines where the match is a complete word
  171.  
  172.      --xx   print only lines where the match is a whole line
  173.  
  174. SSEEEE AALLSSOO
  175.      emacs(1), ed(1), sh(1), _G_N_U _E_m_a_c_s _M_a_n_u_a_l
  176.  
  177. IINNCCOOMMPPAATTIIBBIILLIITTIIEESS
  178.      The following incompatibilities with UNIX _g_r_e_p exist:
  179.  
  180.           The context-dependent meaning of * is not quite the
  181.           same (grep only).
  182.  
  183.           --bb prints a byte offset instead of a block offset.
  184.  
  185.           The {_m,_n} construct of System V grep is not imple-
  186.           mented.
  187.  
  188. BBUUGGSS
  189.      GNU _e?_g_r_e_p has been thoroughly debugged and tested by
  190.      several people over a period of several months; we think
  191.      it's a reliable beast or we wouldn't distribute it.  If by
  192.  
  193.  
  194.  
  195. GNU Project             1988 December 13                        3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. GREP                      User Commands                      GREP
  203.  
  204.  
  205.  
  206.      some fluke of the universe you discover a bug, send a
  207.      detailed description (including options, regular expres-
  208.      sions, and a copy of an input file that can reproduce it) to
  209.      me, mike@wheaties.ai.mit.edu.
  210.  
  211.      There is also a newsgroup, gnu.utils.bug, for reporting FSF
  212.      utility programs' bugs and fixes; but before reporting some-
  213.      thing as a bug, please try to be sure that it really is a
  214.      bug, not a misunderstanding or a deliberate feature.  Also,
  215.      include the version number of the utility program you are
  216.      running in _e_v_e_r_y bug report that you send in.  Please do not
  217.      send anything but bug reports to this newsgroup.
  218.  
  219. AAVVAAIILLAABBIILLIITTYY
  220.      GNU _g_r_e_p is free; anyone may redistribute copies of _g_r_e_p to
  221.      anyone under the terms stated in the GNU General Public
  222.      License, a copy of which may be found in each copy of _G_N_U
  223.      _E_m_a_c_s.  See also the comment at the beginning of the source
  224.      code file grep.c.
  225.  
  226.      Copies of GNU _g_r_e_p may sometimes be received packaged with
  227.      distributions of Unix systems, but it is never included in
  228.      the scope of any license covering those systems.  Such
  229.      inclusion violates the terms on which distribution is per-
  230.      mitted.  In fact, the primary purpose of the General Public
  231.      License is to prohibit anyone from attaching any other res-
  232.      trictions to redistribution of any of the Free Software
  233.      Foundation programs.
  234.  
  235. AAUUTTHHOORRSS
  236.      Mike Haertel wrote the deterministic regexp code and the
  237.      bulk of the program.
  238.  
  239.      James A. Woods is responsible for the hybridized search
  240.      strategy of using Boyer-Moore-Gosper fixed-string search as
  241.      a filter before calling the general regexp matcher.
  242.  
  243.      Arthur David Olson contributed code that finds fixed strings
  244.      for the aforementioned BMG search for a large class of
  245.      regexps.
  246.  
  247.      Richard Stallman wrote the backtracking regexp matcher that
  248.      is used for \_d_i_g_i_t backreferences, as well as the getopt
  249.      that is provided for 4.2BSD sites.  The backtracking matcher
  250.      was originally written for GNU Emacs.
  251.  
  252.      D. A. Gwyn wrote the C alloca emulation that is provided so
  253.      System V machines can run this program.  (Alloca is used
  254.      only by RMS' backtracking matcher, and then only rarely, so
  255.      there is no loss if your machine doesn't have a "real"
  256.      alloca.)
  257.  
  258.  
  259.  
  260.  
  261. GNU Project             1988 December 13                        4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. GREP                      User Commands                      GREP
  269.  
  270.  
  271.  
  272.      Scott Anderson and Henry Spencer designed the regression
  273.      tests used in the "regress" script.
  274.  
  275.      Paul Placeway wrote the original version of this manual
  276.      page.
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327. GNU Project             1988 December 13                        5
  328.  
  329.  
  330.  
  331.